package com.example.demo.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
@RefreshScope
public class TestController {
    private Logger log = LoggerFactory.getLogger(TestController.class);
    @Value("${app:demo}")
    private String app;
    @Value("${version:1}")
    private String version;

    @Value("${app.name:blank}")
    private String name;


    @Value("${spring.application.name:blank}")
    private String appName;
    @GetMapping("test")
    public String test() {
        log.info("调用service02的test方法");
        try {
            Thread.sleep(4000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "test2: " + app + version;
    }
    @GetMapping("key")
    public String testKey() {
        return "配置文件的值：" + name;
    }

    @GetMapping("config")
    public String config() {
        return "配置文件的值：" + appName;
    }
}
